package com.kingre.et.util;

import java.math.BigDecimal;

public class FormulaUtils {

    public static int generatorStandardScore(double originalScore, float meanScore, float sd) {
        double score = ((originalScore - meanScore) / sd) + 5.5;
        int iScore = (new BigDecimal(score).setScale(0, BigDecimal.ROUND_HALF_UP)).intValue();
        if (iScore > 10)
            return 10;
        if (iScore < 1)
            return 1;
        return iScore;
    }

    public static int getAVGToInt(int... values) {
        int subValue = 0;

        for (int v : values) {
            subValue += v;
        }
        return (new BigDecimal((subValue * 1.0) / values.length).setScale(0, BigDecimal.ROUND_HALF_UP)).intValue();
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // double d = 4.66;
        //
        // System.out.println("四舍五入取整:=" + new BigDecimal(d).setScale(0,
        // BigDecimal.ROUND_HALF_UP));
        System.out.println(getAVGToInt(3, 4, 4));
    }

}
